package com.woniuxy.hrm.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class ResponseData<T> {
    private Integer code;
    private T data;
    private String msg;
    //封装两个方法，一个成功的方法，一个失败方法
    public static <T> ResponseData<T> ok(){
        return new ResponseData<>(ResponseEnum.SUCCESS.getCode(),null,ResponseEnum.SUCCESS.getMsg());
    }
    public static <T> ResponseData<T> ok(T data){
        return new ResponseData<>(ResponseEnum.SUCCESS.getCode(),data,ResponseEnum.SUCCESS.getMsg());
    }
    public static <T> ResponseData<T> fail(ResponseEnum responseEnum){
        return new ResponseData<>(responseEnum.getCode(),null,responseEnum.getMsg());
    }
}
